package main

import (
	service "bstream_product/b_service"
	"context"
	"fmt"
	"google.golang.org/grpc"
)

func GetProductStock(client service.ProdServiceClient, req *service.ProductRequest) (*service.ProductResponse, error) {
	return client.GetProductStock(context.Background(), req)
}

func main() {
	// 1 启动grpc的dial设定服务端host:port
	client, err := grpc.DialContext(
		context.Background(),
		"127.0.0.1:3003",
		grpc.WithInsecure(), grpc.WithBlock())
	if err != nil {
		fmt.Println("获取grpc服务", err)
	}
	c := service.NewProdServiceClient(client)
	result, err := GetProductStock(c, &service.ProductRequest{ProdId: 1})
	if err != nil {
		fmt.Println("er", err)
		return
	}
	fmt.Println("显示服务端返回的数据", result)

}
